<%-- 
    Document   : cliente
    Created on : 17/01/2013, 10:01:23 PM
    Author     : Administrador
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/javascript_proyecto_gnm.js" ></script>
        <link rel="stylesheet" href="/resources/demos/style.css" />

        <style type="text/css">

            * { font-family: Verdana; font-size: 96%; }
            label { width: 10em; float: left; }
            label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
            p { clear: both; }
            .submit { margin-left: 12em; }
            em { font-weight: bold; padding-right: 1em; vertical-align: top; }

        </style>
        <script>
            $(document).ready(function(){
                
                $('input').addClass("ui-corner-all");
                
                $.validator.addMethod("valueNotEquals", function(value, element, arg){
                    return arg != value;
                }, "Value must not equal arg.");

                $("#commentForm").validate({
                    
                    rules: {
                        Nro:"required",
                        FechaNac:"required",
                        ncboGenero:{
                            required: true,  
                            valueNotEquals: '00' 
                        },
                        cTipoPas:{
                            required: true,  
                            valueNotEquals: '00' 
                        }
                    },
                    
                    messages: {
                        Nro:"Ingresar NUmero",
                        FechaNac:"Ingresar fecha de nacimiento",
                        ncboGenero: "Seleccionar Genero",
                        cTipoPas: "Seleccionar tipo"
                    },
                    submitHandler: function() { 
                       
                        var hf = parent.document.getElementById('hfCodigo').value;
                        
                        txt = 'txtName' + hf;
                        var txtName = parent.document.getElementById(txt);
                        txtName.value = document.getElementById('cNombre').value;
                        
                        txt = 'txtDate' + hf;
                        var txtDate = parent.document.getElementById(txt);
                        txtDate.value = document.getElementById('cFechaNac').value;
                        
                        txt = 'txtGenero' + hf;
                        var txtGenero = parent.document.getElementById(txt);
                        txtGenero.value = document.getElementById('cboGenero').value;
                        
                        txt = 'txtStrPassenegerType' + hf;
                        var txtStrPassenegerType = parent.document.getElementById(txt);
                        txtStrPassenegerType.value = document.getElementById('cboTipoPas').value;
                        
                        txt = 'txtStrReferenceType' + hf;
                        var txtStrReferenceType = parent.document.getElementById(txt);
                        if(document.getElementById('cboTipoDoc').value == '01')
                            txtStrReferenceType.value = 'DNI';
                        
                        //alert(document.getElementById('cboGenero').value + ' - ' + txtGenero.value);
                        
                        btCancelar();
                        
                    }
                })
                
            });
            
            function btCancelar(){
                parent.PRUEBA_CERRAR();
            }
            
            function inicio(){
      
                var hf = parent.document.getElementById('hfCodigo').value;
                
                var txt = 'txtNum' + hf;
                var txtNro = parent.document.getElementById(txt);
                document.getElementById('cNro').value = txtNro.value;
                
                
                txt = 'txtName' + hf;
                var txtName = parent.document.getElementById(txt);
                document.getElementById('cNombre').value = txtName.value;
                
                txt = 'txtSurname' + hf;
                var txtSurname = parent.document.getElementById(txt);
                document.getElementById('cApellido').value = txtSurname.value;
                
                txt = 'txtDate' + hf;
                var txtDate = parent.document.getElementById(txt);
                if(txtDate != null || txtDate.value != '')
                    document.getElementById('cFechaNac').value = txtDate.value;
                else
                    document.getElementById('cFechaNac').value = "";
                
                
                
                try{
                    txt = 'txtGenero' + hf;
                    var txtGenero = parent.document.getElementById(txt);
                    if(txtGenero != null && txtGenero.value != 'null' && txtGenero.value != '')
                        document.getElementById('cboGenero').value = txtGenero.value;
                    else
                        document.getElementById('cboGenero').value = "00";
                    
                        
                }catch(e){
                    alert(e);
                    document.getElementById('cboGenero').value = "00";
                }
                
                
            
                try{
                    txt = 'txtStrPassenegerType' + hf;
                    var txtStrPassenegerType = parent.document.getElementById(txt);
                    if(txtStrPassenegerType !=null && txtStrPassenegerType.value != 'null' && txtStrPassenegerType.value != '')
                        document.getElementById('cboTipoPas').value = txtStrPassenegerType.value;
                    else
                        document.getElementById('cboTipoPas').value = "00";
                }catch(e){
                    document.getElementById('cboTipoPas').value = "00";
                }
                

                try{   
                        
                    txt = 'txtStrReferenceType' + hf;
                    var txtStrReferenceType = parent.document.getElementById(txt);
                    if(txtStrReferenceType !=null && txtStrReferenceType.value != 'null' && txtStrReferenceType.value != ''){
                        
                        if(txtStrReferenceType.value == 'DNI')
                            document.getElementById('cboTipoDoc').value = '01';
                    }
   
                    else
                        document.getElementById('cboTipoDoc').value = "00";
                }catch(e){
                    document.getElementById('cboTipoDoc').value = "00";
                }
                
                
                txt = 'txtStrReferenceNumber' + hf;
                var txtStrReferenceNumber = parent.document.getElementById(txt);
                
                if(txtStrReferenceNumber !=null || txtStrReferenceNumber.value != '')
                    document.getElementById('cNrodoc').value = txtStrReferenceNumber.value;
                else
                    document.getElementById('cNrodoc').value = "";
                    
                
                
            }
            
        </script>		
    </head>
    <body onload="inicio();">
        <form class="cmxform" id="commentForm" name="commentForm" method="post" action="">


            <table width="100%" >

                <tr>
                    <td width="2%" ></td>
                    <td width="10%" >
                        <label for="cname">Nro</label>
                    </td>
                    <td>

                        <em>*</em><input id="cNro" name="Nro" size="25" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <label for="cNombre">Nombre</label>
                    </td>
                    <td>

                        <em>*</em><input id="cNombre" name="Nombre" size="25"   />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <label for="cApellido">Apellido</label>
                    </td>
                    <td>
                        <em>*</em><input id="cApellido" name="Apellido" size="25" />
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td> 
                        <label for="cFechaNac">Fecha de Nacimiento</label>
                    </td>
                    <td>
                        <em>*</em>
                        <input id="cFechaNac" name="FechaNac" 
                               maxlength="10" onkeydown="return f_OnKeyDown_fechaedad(this);" onkeyup="return f_OnKeyUp_fechaedad(this);" onkeypress="return f_solo_numeros(event);"  />
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <label  for="nGenero">Genero</label>
                    </td>
                    <td><em>*</em><select id="cboGenero" name="ncboGenero"  >
                            <option value="00" >-- Seleccionar --</option>
                            <option value="M" >Masculino</option>
                            <option value="F"  >Femenino</option>
                        </select>
                    </td>
                </tr

                <tr>
                    <td></td>
                    <td>
                        <label  for="cTipoPas">Tipo de Pasajero</label>
                    </td>
                    <td>
                        <em>*</em><select id="cboTipoPas" name="cTipoPas" class="required" >
                            <option value="00" >-- Seleccionar --</option>
                            <option value="A" >Adulto</option>
                            <option value="N" >Niño</option>
                            <option value="I" >Infante</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <label  for="cTipoDoc" >Tipo de Documento</label>
                    </td>
                    <td>
                        <em>*</em><select id="cboTipoDoc" name="select" >
                            <option value="00" >-- Seleccionar --</option>
                            <option value="01" >DNI</option>
                            <option value="02" >C. Extranjeria</option>
                            <option value="03" >Pasaporte</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <label for="cNrodoc">N&uacute;mero de Documento</label>
                    </td>
                    <td>
                        <em>*</em><input id="cNrodoc" name="Nrodoc" size="25" class="required" />
                    </td>
                </tr>

            </table>


            <input id="btnGrabar" name="btnGrabar" type="submit" value="Submit"/>
            <input type="button" name="Btn_Cancelar" value="Cancelar" id="Btn_Cancelar" onclick="btCancelar();" />




        </form>
    </body>   
</html>
